#ifndef _TFT_HX8347_CFG_H_
#define _TFT_HX8347_CFG_H_

#define SPI_PORT         2  //0 FriendlyARM nanopi,1 CZ Ext Board,2 Bananapi-m2 zero

// BASE ADDR
#define GPIO_BASE_ADDRESS 			(0x01C20800)

#if SPI_PORT==0
    //SPI1
    //MOSI  PC0 2*0x24+0x00 = 0x48
    #define PIN_MOSI_DIRECTION_ADDR_OFFSET      0x48
    #define PIN_MOSI_VALUE_ADDR_OFFSET          0x58
    #define PIN_NUM_MOSI                        0
    //MISO  PC1
    #define PIN_MISO_DIRECTION_ADDR_OFFSET      0x48
    #define PIN_MISO_VALUE_ADDR_OFFSET          0x58
    #define PIN_NUM_MISO                        1
    //CLK  PC2
    #define PIN_CLK_DIRECTION_ADDR_OFFSET       0x48
    #define PIN_CLK_VALUE_ADDR_OFFSET           0x58
    #define PIN_NUM_CLK                         2
    //CS  PC3
    #define PIN_CS_DIRECTION_ADDR_OFFSET        0x48
    #define PIN_CS_VALUE_ADDR_OFFSET            0x58
    #define PIN_NUM_CS                          3
    //RESET  PG11
    #define PIN_RESET_DIRECTION_ADDR_OFFSET     0xDC
    #define PIN_RESET_VALUE_ADDR_OFFSET         0xE8
    #define PIN_NUM_RESET                       11
    //DC  PA1
    #define PIN_DC_DIRECTION_ADDR_OFFSET        0x0
    #define PIN_DC_VALUE_ADDR_OFFSET            0x10
    #define PIN_NUM_DC                          1
#elif SPI_PORT==1
    //MOSI  PA15 
    #define PIN_MOSI_DIRECTION_ADDR_OFFSET      0x04
    #define PIN_MOSI_VALUE_ADDR_OFFSET          0x10
    #define PIN_NUM_MOSI                        15
    //MISO  PA16
    #define PIN_MISO_DIRECTION_ADDR_OFFSET      0x08
    #define PIN_MISO_VALUE_ADDR_OFFSET          0x10
    #define PIN_NUM_MISO                        16
    //CLK  P14
    #define PIN_CLK_DIRECTION_ADDR_OFFSET       0x04
    #define PIN_CLK_VALUE_ADDR_OFFSET           0x10
    #define PIN_NUM_CLK                         14
    //CS  PA13
    #define PIN_CS_DIRECTION_ADDR_OFFSET        0x04
    #define PIN_CS_VALUE_ADDR_OFFSET            0x10
    #define PIN_NUM_CS                          13
    //RESET  PG11
    #define PIN_RESET_DIRECTION_ADDR_OFFSET     0xDC
    #define PIN_RESET_VALUE_ADDR_OFFSET         0xE8
    #define PIN_NUM_RESET                       11
    //DC  PA1
    #define PIN_DC_DIRECTION_ADDR_OFFSET        0x0
    #define PIN_DC_VALUE_ADDR_OFFSET            0x10
    #define PIN_NUM_DC                          1
#elif SPI_PORT==2
    //MOSI  PC0 2*0x24+0x00 = 0x48
    #define PIN_MOSI_DIRECTION_ADDR_OFFSET      0x48
    #define PIN_MOSI_VALUE_ADDR_OFFSET          0x58
    #define PIN_NUM_MOSI                        0
    //MISO  PC1
    #define PIN_MISO_DIRECTION_ADDR_OFFSET      0x48
    #define PIN_MISO_VALUE_ADDR_OFFSET          0x58
    #define PIN_NUM_MISO                        1
    //CLK  PC2
    #define PIN_CLK_DIRECTION_ADDR_OFFSET       0x48
    #define PIN_CLK_VALUE_ADDR_OFFSET           0x58
    #define PIN_NUM_CLK                         2
    //CS  PC3
    #define PIN_CS_DIRECTION_ADDR_OFFSET        0x48
    #define PIN_CS_VALUE_ADDR_OFFSET            0x58
    #define PIN_NUM_CS                          3
    //RESET  PA6
    #define PIN_RESET_DIRECTION_ADDR_OFFSET     0x0
    #define PIN_RESET_VALUE_ADDR_OFFSET         0x10
    #define PIN_NUM_RESET                       6
    //DC  PA2
    #define PIN_DC_DIRECTION_ADDR_OFFSET        0x0
    #define PIN_DC_VALUE_ADDR_OFFSET            0x10
    #define PIN_NUM_DC                          2
#endif



// 主设备号
#define CHRDEV_MAJOR 242  

#endif